#!/usr/bin/env python

import wx
from _base import Base

class Viewer(Base):
    
    def bind(self):
        super(Viewer, self).bind()
        view = self.view
        tool = view.ToolBar
        
        view.canvas.Bind(wx.EVT_MOTION, self.onMotion)
        view.canvas.Bind(wx.EVT_LEFT_DOWN, self.onLeftDown)
        view.Bind(wx.EVT_MENU, self.open, tool.open.tool)
        tool.amplitude.Bind(wx.EVT_COMBOBOX, self.onAmplitude)
        tool.time.Bind(wx.EVT_COMBOBOX, self.onTime)
        
    def onMotion(self, event):
        self.presenter.move(event.Position)
        event.Skip()
    
    def onLeftDown(self, event):
        self.presenter.click(event.Position)
        event.Skip()
    
    def onAmplitude(self, event):
        self.presenter.changeAmplitude(int(event.String))
        event.Skip()
        
    def onTime(self, event):
        self.presenter.changeTime(int(event.String))
        event.Skip()
        
    def open(self, event):
        self.presenter.open()
        event.Skip()